package com.example.demo.zaqizabatest.多线程相关;

import lombok.SneakyThrows;

import java.io.*;
import java.util.Scanner;
import java.util.concurrent.*;

/**
 * @ClassName ABC
 * @Author lys4134
 * @Date 2021/09/01 17:41:14
 * @Description ABC
 * @Version 1.0
 **/
public class ABC implements Runnable {
    @SuppressWarnings("AlibabaThreadShouldSetName")
    static ExecutorService executorService =new ThreadPoolExecutor(1, 1,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>());
    private String s;

    public ABC(String s) {

        this.s = s;
    }

    public static void main(String[] args) {

        //读取文本文件的内容
//        Scanner scanner = null;
//        try {
//            scanner = new Scanner(new File("D://read.txt"));
//            while (scanner.hasNext()) {
//                System.out.println(scanner.nextLine());
//            }
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        } finally {
//            if (scanner != null) {
//                scanner.close();
//            }
//        }




        int i = 0;
        while (i < 100){
            i++;
            for (String s : "ABC".split("")){
                executorService.submit(new ABC(s));
            }
        }
        executorService.shutdown();
    }

    @SneakyThrows
    @Override
    public void run() {
        System.out.print(s + " ");
    }
}
